package be.dch.objectprops.formatter;

public class CharacterFormatter implements Formatter {

    @SuppressWarnings("rawtypes")
    
    public Class getFormatterClass() {
	return Character.class;
    }

    
    public String format(final Object obj) {
	final Character character = (Character) obj;
	return character.toString();
    }

    
    public Object parse(final String input) {
	if ((input == null) || (input.length() == 0)) {
	    return null;
	}
	if (input.length() == 1) {
	    return new Character(input.charAt(0));
	}
	throw new IllegalArgumentException("Can't parse string '" + input + "' into a character");
    }

    public void parse(final String input, Object result) {
	throw new UnsupportedOperationException("Method parse(String,Object) not supporeted.");
    }
}
